

var newer = newer || {};
newer.gd = newer.gd || {};

newer.CirclesHelper = {
	gotoCircleHandler: function(event) {
		$.debug("dd");
		var self = event.data.self;
		var newurl = location.pathname;
		var origPtype = newer.gd.pstatus.ptype;

		newurl = "/newer/"+newer.UriHelper.PEOPLE_TYPE+"/" + event.data.cid + "/t/about/";

		history.pushState({}, "", newurl);
		
		newer.UriHelper.getGlobals();
		if(self.prt) {
			self.prt.trigger(origPtype + " goto circle");
		} else if(self.nroot) {
			self.nroot.nmsg(origPtype + " goto circle");
		} else {
			document.location.href = newurl;
		}
		
	},
	
	updateCirclePhotoSrc: function(circle) {
		if(circle.hasPhoto==true) {
			$("img#c"+circle.id).attr("src", "/Circles/displayCirclePhoto?cid="+circle.id);
		} else if (circle.hasMap == true) {
			$("img#c"+circle.id).attr("src", "/Circles/displayCircleMap?cid="+circle.id);
		} else {
			$.post("/Circles/updateCircleMap?cid="+circle.id, {}, function(){
				circle.hasMap = true;
				$("img#c"+circle.id).attr("src", "/Circles/displayCircleMap?cid="+circle.id);
			})
		}
	},
	
	showOneCircle: function(circle) {
		var res = "<td><div><img height=150px class='link-like-element' id=\"c" + circle.id +"\"></div><div>"+circle.name+"</div></td>";
		return res;
	}
	
};